package com.newcapec.news.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Description: 登录页面的展示
 * @Author: fujun
 * @Date : 2022/3/16 16:08
 * @Version : 1.0
 * @company 新开普电子股份有限公司
 */
public class ShowLoginHtmlServlet  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//            req.setCharacterEncoding("utf-8");
//            resp.setCharacterEncoding("utf-8");



        String type=req.getParameter("type");
        String msg="";

        if(type!=null){

            switch (type){
                case "1":
                    msg="用户名不存在";
                    break;
                case "2":
                    msg="密码错误";
                    break;
                case "3":
                    msg="没有权限访问该页面，请登录后进行访问";
                    break;
                case "4":
                    msg="验证码错误，请重新输入";
                    break;
            }

        }


           // 将servlet中的数据传递给jsp页面

        //  request作用域，session作用域 ，application作用域
        req.setAttribute("msg",msg);

        req.getRequestDispatcher("WEB-INF/page/login.jsp").forward(req,resp);




    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
